<?php
namespace frontend\controllers;

use yii\web\Controller;
use Yii;
use yii\web\Cookie;

class HelloController extends Controller{
    public function actionIndex(){
        $session = Yii::$app->session;

        if ($session->isActive){
            echo "session is open";
        }

        $cookies = Yii::$app->response->cookies;
        $cookies->add(new Cookie(['name'=>'user','value'=>'william']));
    }
}